<?php
session_start();
isLogin();

if(isset($_POST["Submits"])){
	if($_REQUEST['act']=='modify'){
		$sql="update ".$prefix."app set a_appkey='".$_POST['a_appkey']."',a_appsecret='".$_POST['a_appsecret']."' where a_id=".$_REQUEST['a_id'];
		if(mysql_query($sql)){
			reload_js("修改成功","index.php?cmd=app");
		}else{
			reload_js("修改失败，原因：程序错误，请联系技术人员进行修改","index.php");
		}
	}else{
		$sql="insert into ".$prefix."app (a_appkey,a_appsecret) values('".$_POST['a_appkey']."','".$_POST['a_appsecret']."')";
		if(mysql_query($sql)){
			reload_js("添加成功","index.php?cmd=app");
		}else{
			reload_js("添加失败，原因：程序错误，请联系技术人员进行修改","index.php");
		}
	}
}

if($_REQUEST['act']=='del'){
	$sql="delete from ".$prefix."app where a_id=".$_REQUEST['a_id'];
	if(mysql_query($sql)){
		reload_js("","index.php?cmd=app");
	}else{
		reload_js("删除失败，原因：程序错误，请联系技术人员进行修改","index.php");
	}
}
?>
<script language="javascript" src="../templates/<?php echo $moban;?>/js/common.js"></script>
<script language="javascript">
changeWebTitle('app管理');
</script>

<div class="ContentRight">
    <div class="ContentRightTop">
      <div class="BarLeft"></div>
      <div class="ContentRightTopText">app管理</div>
      <div class="BarRight"></div>
      <div class="Cal"></div>
    </div>
    <div class="ContentRightBox">
	<form action="" name="linkform" method="post">
      <table width="100%" cellpadding="0" class="Table1" bordercolor="#4ab902" border="1" cellspacing="0">
        <tr>
          <td height="25" align="center">ID</td>
          <td align="center">appkey</td>
          <td align="center">appsecret</td>
          <td align="center">操作</td>
        </tr>
		<?php 
		$result=mysql_query("select * from ".$prefix."app");
		while($arr=mysql_fetch_array($result)){
		?>
        <tr>
          <td width="19%" height="25" align="center"><?php echo $arr['a_id']?></td>
          <td width="52%" align="center"><?php echo $arr['a_appkey']?></td>
          <td width="13%" align="center"><?php echo $arr['a_appsecret'];?></td>
          <td width="16%" align="center"><a href="<?php echo "?cmd=".$_REQUEST['cmd']."&a_id=".$arr['a_id']."&act=modify"?>">修改</a>&nbsp;<a href="<?php echo "?cmd=".$_REQUEST['cmd']."&a_id=".$arr['a_id']."&act=del"?>" onclick="return confirm('您确认删除该条记录？删除后将不可恢复！');">删除</a></td>
        </tr>
		<?php }
		
		if($_REQUEST['act']=='modify'){
			$result=mysql_query("select * from ".$prefix."app where a_id=".$_REQUEST['a_id']);
			if($arr=mysql_fetch_array($result)){
				$a_appkey=$arr['a_appkey'];
				$a_appsecret=$arr['a_appsecret'];
			}
		}
		?>
        <tr>
          <td height="25" colspan="4" align="right">&nbsp;</td>
        </tr>
        <tr>
          <td height="25" align="right">appkey：</td>
          <td colspan="3"><input name="a_appkey" type="text" id="a_appkey" size="40"  value="<?php echo $a_appkey?>" onKeyUp="value=value.replace(/[^\d]/gi,'');"/>
          <a href="http://www.fengsh8.com/taoketuiguang/jiaocheng132.html" target="_blank">什么是appKey，如何获取？</a></td>
        </tr>
        <tr>
          <td height="25" align="right">appsecret：</td>
          <td colspan="3"><input name="a_appsecret" type="text" id="a_appsecret" size="40"  value="<?php echo $a_appsecret?>"/></td>
        </tr>
        <tr>
          <td height="25" align="right">版权所有：</td>
          <td colspan="3"><a href="http://www.fengsh8.com" target="_blank">风尚淘客程序</a></td>
        </tr>
        <tr>
          <td height="25" align="right">&nbsp;</td>
          <td colspan="3">
            <input name="Submits" type="submit" id="Submits" value=" 提  交" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input name="Reset" type="reset" id="Reset" value=" 重 置 " />          </td>
        </tr>
      </table>
	  </form>
    </div>
    <div class="Cal"></div>
  </div>